import { DisableUUid32Dto } from "~/rest";
import { INTEGER_PG } from "~/db.pg";

import { TonOrderGroupGateway, TonOrderGateway } from "./dto.order";
import { TonOrder, TonOrderGroup } from "./schema.order";
import { TonSku } from "./schema.sku";
import { Book } from "@/pond-book/schema.book";

export const TonGroupRpcGetOrderGroupPath = `${TonOrderGroupGateway.path}/getOrderGroup`;
export type getOrderGroupRpcDto = { ids: INTEGER_PG[] };

export const TonOrderRpcGetOrderPath = `${TonOrderGateway.path}/getOrder`;
export type getOrderRpcDto = { ids: TonOrder["uuid32"][] };

export const TonOrderRpcDoBusyCheckPath = `${TonOrderGateway.path}/doBusyCheck`;
export const TonOrderRpcDisableOrderPath = `${TonOrderGateway.path}/disableOrder`;

export interface TonOrderComRpcInterface<T> {
  getOrderGroup(dto: T & getOrderGroupRpcDto): Promise<{ entityLs: TonOrderGroup[] }>;
  getOrder(dto: T & getOrderRpcDto): Promise<{ entityLs: TonOrder[] }>;

  doBusyCheck(dto: T & { maskTask?: number }): Promise<{ count: number }>;
  disableOrderSync(dto: T & DisableUUid32Dto): Promise<{ updated: TonOrder; affected: TonSku[] }>;
}
